﻿<fluent:RibbonTabItem x:Class="XSemmel.Schema.Ribbon.ValidationTab"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
            xmlns:commands="clr-namespace:XSemmel.Schema.Commands"
            xmlns:Commands="clr-namespace:XSemmel.Commands" mc:Ignorable="d" 
            xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
            Header="Validation">
    <fluent:RibbonTabItem.Resources>
        <commands:Xml2XsdGeneratorCommand x:Key="Xml2XsdGeneratorCommand"/>
        <commands:InsertXsdLocationCommand x:Key="InsertXsdLocationCommand"/>
        <Commands:TidyInvalidXmlCommand x:Key="TidyInvalidXmlCommand"/>
        <Commands:TrimXmlCommand x:Key="TrimXmlCommand"/>
    </fluent:RibbonTabItem.Resources>

    <fluent:RibbonGroupBox Header="Validation" Icon="/Images/112_Tick_Green_32x32_72.png" >

        <StackPanel >
            <StackPanel Orientation="Horizontal">
                <fluent:ToggleButton
                                Header="Do not check" Padding="30,0,30,0"
                                SizeDefinition="Middle, Small"
                                IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data.ValidationData.DoNotValidate}" />
                <fluent:ToggleButton
                                Header="Check wellformedness" Padding="5,0,5,0"
                                SizeDefinition="Middle, Small"
                                IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data.ValidationData.CheckWellformedness}"/>
            </StackPanel>
            <fluent:ToggleButton 
                            x:Name="chkValidateXsd" Header="Validate against schema" Click="chkValidateXsd_Click"
                            SizeDefinition="Middle, Small"
                            IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data.ValidationData.CheckXsd}"/>

            <Border CornerRadius="2"
                    BorderBrush="LightGray"
                    BorderThickness="1"
                    Padding="1">
                <StackPanel Orientation="Horizontal" x:Name="edtInput" IsEnabled="{Binding ElementName=chkValidateXsd, Path=IsChecked}">
                    <Label Padding="3 0 3 0" VerticalAlignment="Center">XSD:</Label>
                    <TextBox x:Name="edtXsdFile" Width="207"
                             Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data.ValidationData.Xsd, UpdateSourceTrigger=PropertyChanged}">
                        <TextBox.ContextMenu>
                            <ContextMenu>
                                <MenuItem Command="Cut">
                                    <MenuItem.Icon>
                                        <Image Source="/Images/cut.png" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <MenuItem Command="Copy">
                                    <MenuItem.Icon>
                                        <Image Source="/Images/copy.png" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <MenuItem Command="Paste">
                                    <MenuItem.Icon>
                                        <Image Source="/Images/Paste_16x16.png" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <Separator/>
                                <MenuItem Header="Edit Xsd File" Click="mnuEditXsd_Click" />
                                <MenuItem Header="Copy file path to clipboard" Click="mnuCopyXsdPath_Click" />
                            </ContextMenu>
                        </TextBox.ContextMenu>
                    </TextBox>
                    <fluent:Button Margin="0" Header="..." Click="mnuSelectXsdFile_Click" SizeDefinition="Middle, Small" Height="18"/>
                </StackPanel>

            </Border>
            
        </StackPanel>
    </fluent:RibbonGroupBox>

    <fluent:RibbonGroupBox Header="Tools" >
        <fluent:Button
            Header="Generate schema (xml2xsd)" 
            LargeIcon="/Images/Generate_XSD_32x32.png" 
            Command="{StaticResource Xml2XsdGeneratorCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data}"
        />

        <fluent:SplitButton Header="Tidy invalid XML" 
                            LargeIcon="/Images/EditTask_32x32.png" 
                            Icon="/Images/EditTask.png" 
                            Command="{StaticResource TidyInvalidXmlCommand}"
                            CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data}">
            <fluent:SplitButton.Items>
                <fluent:MenuItem Header="Trim"
                                 ToolTip="Trims and prettyprints invalid XML"
                                 Icon="/Images/EditTask.png" 
                                Command="{StaticResource TrimXmlCommand}" 
                                CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data}"/>
                <!--<fluent:MenuItem Header="Escape XML"
                                Command="{StaticResource EscapeXmlStringCommand}" 
                                CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data}"/>-->
            </fluent:SplitButton.Items>
        </fluent:SplitButton>

          
        <fluent:Button
            Header="Bulk"
            ToolTip="Validates multiple files"
            LargeIcon="/Images/112_Tick_Green_32x32_72.png"
            Click="mnuBulkValidateXsd_Click"
        />
        <fluent:Button
            Header="Insert XSD location" 
            Icon="/Images/RelationshipsHS.png"
            SizeDefinition="Middle, Small"
            Command="{StaticResource InsertXsdLocationCommand}"
            CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fluent:RibbonWindow}}, Path=Data}"
        />
    </fluent:RibbonGroupBox>

</fluent:RibbonTabItem>
